#ifndef RSSREADER_H
#define RSSREADER_H

#include <QObject>

#include "rssfeed.h"


class RssReader : QObject {
        Q_OBJECT
    private:
        QList<RssFeed*>* feeds;
        QIcon stateNewIcon;
        QIcon stateNormalIcon;
        QIcon stateProblemIcon;
		QString path;

	public slots:
		void deleteLater();

    public:
		RssReader(const QString &path);
		~RssReader() {
            delete feeds;
        }

		QString getPath() const {
			return path;
		}

		void setPath(const QString &path) {
			this->path = path;
		}

		void removeFeed(const QString &name);
		void removeCategory(const QString &category);
        QList<RssFeed*> *getFeeds();
		RssFeed *getFeedByName(const QString &name);
		QList<RssFeed*> getFeedsByCategory(const QString &category);
        QStringList getCategories();
        RssItem *getItemByLink(const QString &link);

        void hideMessages(bool onlySeen);
        void trashAllMessages();
        void unhideMessages();

        int countOfUnseenMessages();
        void markReader(bool read);
		void editCategory(const QString &oldCategory, const QString &newCategory);
        bool addFeed(RssFeed *feed);
        bool canBeAdded(RssFeed *feed);
		bool canBeAdded(const QString &title, const QString &link);
        bool canBeEdited(RssFeed *oldOne, RssFeed *newOne);
        bool editFeed(RssFeed *oldOne, RssFeed *newOne);

        void updateRepresentation(QTreeWidget *widget);
        void updateColors(QTreeWidget *widget);

		bool saveXml(const QString &filename);
		void loadXml(bool append, const QString &filename);

		void saveOpml(const QString &filename);
		void loadOpml(bool append, const QString &filename);

};


#endif // RSSREADER_H
